package com.woniu.p2p.behindServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.p2p.behindService.PersonManagerService;
import com.woniu.p2p.entity.Admin;
import com.woniu.p2p.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * manageServiceImpl
 *
 *
 */
@Service
public class PersonManagerServiceImpl implements PersonManagerService {

    @Autowired
    AdminMapper adminMapper;

    @Override
    public PageInfo<Admin> findAdminByStatusAndName(Integer status, String name,Integer start) {
        PageHelper.startPage(start,3);

        List<Admin> admins = adminMapper.selectByStatusAndName(status, name);
        PageInfo<Admin> pageInfo=new PageInfo<>(admins);
        return pageInfo;
    }

    @Override
    public Admin selectByAdminId(Integer adminId) {
        return adminMapper.selectByPrimaryKey(adminId);
    }

    @Override
    public int updateAdmin(Admin admin) {
        return adminMapper.updateByPrimaryKey(admin);
    }

    @Override
    public int addAdmin(Admin admin) {
        return adminMapper.insert(admin);
    }

    @Override
    public int delAdmin(Integer adminId) {
        return adminMapper.deleteByPrimaryKey(adminId);
    }
}
